package com.example.yuanboot.controller;

import com.example.yuanboot.common.msg.BaseResultCode;
import com.example.yuanboot.common.msg.ObjectRestResponse;
import com.example.yuanboot.common.msg.ResponseUtils;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 鉴权Controller
 *
 * @author qingyan 2021-06-18
 */
//@ApiRestController("/auth")
@RestController
@RequestMapping("/auth")
@Validated // 让RequestParam和PathVariable 参数校验生效（只能用在类上）
public class AuthController {

    @GetMapping("/check")
    public ObjectRestResponse check(Authentication authentication){
        return ResponseUtils.r(authentication.getName(), BaseResultCode.SUCCESS);
    }

}
